﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

using LowLevelGraphics.Types.Interval;

namespace LowLevelGraphics.Extractors
{
    /// <summary>
    /// 
    /// </summary>
    public class PointListEvaluator
    {
        protected IEnumerable<Point> m_aPoint = null;

        protected IntInterval m_iX = null;
        protected IntInterval m_iY = null;

        /// <summary>
        /// Initializes a new instance of the <see cref="PointListEvaluator"/> class.
        /// </summary>
        /// <param name="_aPoint">The _a point.</param>
        public PointListEvaluator(IEnumerable<Point> _aPoint)
        {
            m_aPoint = _aPoint;

            int nMaxX = -1;
            int nMaxY = -1;

            int nMinX = int.MaxValue - 2;
            int nMinY = int.MaxValue - 2;

            foreach (Point pt in m_aPoint)
            {
                if (pt.X > nMaxX) nMaxX = pt.X;
                if (pt.X < nMinX) nMinX = pt.X;
                if (pt.Y > nMaxY) nMaxY = pt.Y;
                if (pt.Y < nMinY) nMinY = pt.Y;
            }

            m_iX = new IntInterval(nMinX, nMaxX);
            m_iY = new IntInterval(nMinY, nMaxY);
        }

        /// <summary>
        /// Gets the X interval.
        /// </summary>
        /// <value>The X interval.</value>
        public IntInterval XInterval
        {
            get { return m_iX; }
        }

        /// <summary>
        /// Gets the Y interval.
        /// </summary>
        /// <value>The Y interval.</value>
        public IntInterval YInterval
        {
            get { return m_iY; }
        }
    }
}
